﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using AutoMapper;
using Data.ModelDatabase;

namespace Data.Mappers
{
    public class CategoryMapper : IMapper<Entity.Categories.Category, Category>
    {
        public Entity.Categories.Category WrapperData(Category category)
        {
            Mapper.CreateMap<Category, Entity.Categories.Category>();
            Mapper.CreateMap<Product, Entity.Products.Product>();

            return Mapper.Map<Category, Entity.Categories.Category>(category);
        }

        public List<Entity.Categories.Category> WrapperData(List<Category> categories)
        {
            Mapper.CreateMap<Category, Entity.Categories.Category>();
            Mapper.CreateMap<Product, Entity.Products.Product>();

            return Mapper.Map<List<Category>, List<Entity.Categories.Category>>(categories);
        }

        public Category WrapperEntity(Entity.Categories.Category category)
        {
            Mapper.CreateMap<Entity.Products.Product, Product>();
            Mapper.CreateMap<Entity.Categories.Category, Category>();

            return Mapper.Map<Entity.Categories.Category, Category>(category);
        }

        public List<Category> WrapperEntity(List<Entity.Categories.Category> categories)
        {
            Mapper.CreateMap<Entity.Products.Product, Product>();
            Mapper.CreateMap<Entity.Categories.Category, Category>();

            return Mapper.Map<List<Entity.Categories.Category>, List<Category>>(categories);
        }
    }
}
